package com.zy.hospitalward_management_system.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        System.out.println("test=>>>addViewControllers正在注册中..");

        registry.addViewController("/").setViewName("index");
        //registry.addViewController("/main.html").setViewName("index");
    }


    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("test=>>>正在添加自定义拦截器...");
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**").excludePathPatterns("/login","/toIndex","/","/index.html","/assets/**","/error","/static/**");
    }


}
